package cn.leaves.wb.db.dao.jdbc;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Service;

import cn.leaves.wb.db.bean.Notice;
import cn.leaves.wb.db.dao.NoticeDAO;

@Service(value = "noticeDAO")
public class NoticeDAOJDBCImpl extends BaseJDBC implements NoticeDAO {
	private Log log = LogFactory.getLog(getClass());

	@Override
	public void save(Notice notice) throws SQLException {
		super.save(notice, new String[] {
		});
	}

	class NoticeRowMapper implements RowMapper<Notice> {

		@Override
		public Notice mapRow(ResultSet rs, int rowNum) throws SQLException {
			Notice notice = new Notice();
			notice.setId(rs.getLong("id"));
			notice.setProfile_id(rs.getLong("profile_id"));
			notice.setUri(rs.getString("uri"));
			notice.setContent(rs.getString("content"));
			notice.setRendered(rs.getString("rendered"));
			notice.setUrl(rs.getString("url"));
			notice.setCreated(rs.getTimestamp("created"));
			notice.setModified(rs.getTimestamp("modified"));
			notice.setReply_to(rs.getLong("reply_to"));
			notice.setIs_local(rs.getShort("is_local"));
			notice.setSource(rs.getString("source"));
			notice.setConversation(rs.getLong("conversation"));
			notice.setLat(rs.getBigDecimal("lat").doubleValue());
			notice.setLon(rs.getBigDecimal("lon").doubleValue());
			notice.setLocation_id(rs.getLong("locationId"));
			notice.setLocation_ns(rs.getLong("locationNs"));
			notice.setRepeat_of(rs.getLong("repeatOf"));
			return notice;
		}

	}

}
